//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include "ListRankStatus.h"
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
ListRankStatus::ListRankStatus() {
  
  this->ranksStatus = new TListE <RankStatus> ();
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
ListRankStatus::ListRankStatus(int size, int status) {
  
  this->ranksStatus = new TListE <RankStatus> ();
  for (int i = 0; i < size; i++) 
    this->ranksStatus->Add(new RankStatus(i, status));
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
ListRankStatus::ListRankStatus(const ListRankStatus& listRankStatus) {
  
  this->ranksStatus = new TListE <RankStatus> (listRankStatus.ranksStatus);
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
ListRankStatus::ListRankStatus(const ListRankStatus* listRankStatus) {
  
  this->ranksStatus = new TListE <RankStatus> (listRankStatus->ranksStatus);
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
ListRankStatus::~ListRankStatus() {
  
  if (this->ranksStatus) 
    delete this->ranksStatus;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
void ListRankStatus::RanksStatus(TListE <RankStatus>* ranksStatus) {
  
  *(this->ranksStatus) = *(ranksStatus);
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
TListE <RankStatus>* ListRankStatus::RanksStatus(void) {
  
  return this->ranksStatus;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
RankStatus* ListRankStatus::NextFreeRank(int status) {
  
  this->ranksStatus->SetInitial();
  
  while (this->ranksStatus->SetNext())
    if (this->ranksStatus->GetCurrent()->Status() == status)
      return this->ranksStatus->GetCurrent();
  
  return NULL;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
RankStatus* ListRankStatus::NextFreeRankExcludeFirst(int status) {
  
  this->ranksStatus->SetInitial();
  this->ranksStatus->SetNext();
  
  while (this->ranksStatus->SetNext())
    if (this->ranksStatus->GetCurrent()->Status() == status)
      return this->ranksStatus->GetCurrent();
  
  return NULL;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
RankStatus* ListRankStatus::GetRank(int rank) {
  
  this->ranksStatus->SetInitial();
  
  while (this->ranksStatus->SetNext())
    if (this->ranksStatus->GetCurrent()->Rank() == rank)
      return this->ranksStatus->GetCurrent();
  
  return NULL;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
ListRankStatus ListRankStatus::operator=(const ListRankStatus& listRankStatus) {
  
  *(this->ranksStatus) = *(listRankStatus.ranksStatus);
  
  return *this;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
